package com.ruoyi.bizsys.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Arrays;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.stereotype.Service;
import com.ruoyi.bizsys.mapper.ExtResolveAccountMapper;
import com.ruoyi.bizsys.domain.ExtResolveAccount;
import com.ruoyi.bizsys.service.IExtResolveAccountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;


/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author african-loan
 * @date 2022-01-05
 */
@Service
public class ExtResolveAccountServiceImpl extends ServiceImpl<ExtResolveAccountMapper, ExtResolveAccount> implements IExtResolveAccountService {

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    @Override
    public ExtResolveAccount selectExtResolveAccountById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param extResolveAccount 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<ExtResolveAccount> selectExtResolveAccountList(ExtResolveAccount extResolveAccount) {
        return this.list(new QueryWrapper<>(extResolveAccount).last("order by id desc"));
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param extResolveAccount 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertExtResolveAccount(ExtResolveAccount extResolveAccount) {
        extResolveAccount.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insert(extResolveAccount);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param extResolveAccount 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateExtResolveAccount(ExtResolveAccount extResolveAccount) {
        return baseMapper.updateById(extResolveAccount);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteExtResolveAccountByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteExtResolveAccountById(Long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public boolean insert(String bankCode, String accountNumber, String accountName) {
        ExtResolveAccount extResolveAccount = new ExtResolveAccount();
        extResolveAccount.setBankCode(bankCode);
        extResolveAccount.setAccountName(accountName);
        extResolveAccount.setAccountNumber(accountNumber);
        extResolveAccount.setCreateTime(new Date());
        return this.save(extResolveAccount);
    }

}
